package com.ygqh.baby.model;

import com.ygqh.baby.ao.PromotionStatus;
import com.ygqh.baby.utils.DateConvertUtils;

import java.util.Date;

public class ActivitySingleGift {
    private String activityName;
    private String sourceSkuCodes;
    private String giftSkuCode;
    private String sourceCode;
    private Date startDate;
    private Date endDate;
    private Boolean checkStock;
    private Long buyCount;
    private Long giveCount;
    private String handler;
    private Date updateTime;
    private boolean channel;


    public PromotionStatus getPromotionStatus() {
        Date currentDate = DateConvertUtils.getDateStart(new Date());
        if (currentDate.compareTo(startDate) < 0) {
            return PromotionStatus.NotStarted;
        } else if (currentDate.compareTo(startDate) >= 0 && currentDate.compareTo(endDate) <= 0) {
            return PromotionStatus.Running;
        } else {
            return PromotionStatus.Completed;
        }
    }

    public ActivitySingleGift() {
        super();
    }

    public ActivitySingleGift(String activityName, String sourceSkuCodes, String giftSkuCode, String sourceCode,
                              Date startDate, Date endDate, Boolean checkStock, String handler, Date updateTime) {
        super();
        this.activityName = activityName;
        this.sourceSkuCodes = sourceSkuCodes;
        this.giftSkuCode = giftSkuCode;
        this.sourceCode = sourceCode;
        this.startDate = startDate;
        this.endDate = endDate;
        this.checkStock = checkStock;
        this.handler = handler;
        this.updateTime = updateTime;
    }

    public boolean isChannel() {
        return channel;
    }

    public void setChannel(boolean channel) {
        this.channel = channel;
    }

    public String getHandler() {
        return handler;
    }

    public void setHandler(String handler) {
        this.handler = handler;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getSourceSkuCodes() {
        return sourceSkuCodes;
    }

    public void setSourceSkuCodes(String sourceSkuCodes) {
        this.sourceSkuCodes = sourceSkuCodes;
    }

    public String getGiftSkuCode() {
        return giftSkuCode;
    }

    public void setGiftSkuCode(String giftSkuCode) {
        this.giftSkuCode = giftSkuCode;
    }

    public String getSourceCode() {
        return sourceCode;
    }

    public void setSourceCode(String sourceCode) {
        this.sourceCode = sourceCode;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        if (startDate != null) {
            startDate = DateConvertUtils.getDateStart(startDate);
        }
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        if (endDate != null) {
            endDate = DateConvertUtils.getDateStart(endDate);
        }
        this.endDate = endDate;
    }

    public Boolean isValid() {
        Date currentDate = DateConvertUtils.getDateStart(new Date());

        if (currentDate.compareTo(startDate) >= 0 && currentDate.compareTo(endDate) <= 0) {
            return true;
        }
        return false;
    }

    public String getActivityName() {
        return activityName;
    }

    public void setActivityName(String activityName) {
        this.activityName = activityName;
    }

    public Boolean getCheckStock() {
        return checkStock;
    }

    public void setCheckStock(Boolean checkStock) {
        this.checkStock = checkStock;
    }

    public Long getBuyCount() {
        return buyCount;
    }

    public void setBuyCount(Long buyCount) {
        this.buyCount = buyCount;
    }

    public Long getGiveCount() {
        return giveCount;
    }

    public void setGiveCount(Long giveCount) {
        this.giveCount = giveCount;
    }

    @Override
    public String toString() {
        return "ActivitySingleGift [activityName=" + activityName + ", sourceSkuCodes=" + sourceSkuCodes
                + ", giftSkuCode=" + giftSkuCode + ", sourceCode=" + sourceCode + ", startDate=" + startDate
                + ", endDate=" + endDate + ", checkStock=" + checkStock + "]";
    }

}
